/**
 * SpringMVC restful 风格
 * 产品特色控制器，控制关于产品特色的一些业务逻辑操作
 * @author yanwl
 * @date 2014-08-20
 */
package com.chnbst.bstyun.controller.user;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.chnbst.bstyun.model.pojo.Menu;
import com.chnbst.bstyun.model.pojo.ProductFeature;
import com.chnbst.bstyun.service.MenuService;
import com.chnbst.bstyun.service.ProductFeatureService;

@Controller
@RequestMapping("/product")
public class ProductFeatureController {
	
	/**
	 * 注入 业务逻辑层
	 */
	@Autowired
	private MenuService menuService;
	@Autowired
	private ProductFeatureService productFeatureService;
	
	/**
	 * http://xxx.com/product
	 * get请求 返回产品特色首页
	 */
	@RequestMapping(method=RequestMethod.GET)
	public ModelAndView advantage(){
		List<Menu> menus = menuService.selectMenus();
		
		/**
		 * 查询所有的产品特色
		 */
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("start", 0);
		map.put("pageSize", Integer.MAX_VALUE);
		
		List<ProductFeature> pfs = productFeatureService.selectProductFeatures(map);
		ModelAndView mav = new ModelAndView();
		
		mav.addObject("menus", menus);
		mav.addObject("pfs", pfs);
		mav.setViewName("advantage/profeature");
		return mav;
	}
	
	/**
	 * http://xxx.com/product/dlms
	 * get请求 返回登录模式页面
	 */
	@RequestMapping(value="/dlms",method=RequestMethod.GET)
	public ModelAndView dlms(){
		List<Menu> menus = menuService.selectMenus();
		
		/**
		 * 查询所有的产品特色
		 */
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("start", 0);
		map.put("pageSize", Integer.MAX_VALUE);
		
		List<ProductFeature> pfs = productFeatureService.selectProductFeatures(map);
		
		ModelAndView mav = new ModelAndView();
		
		mav.addObject("menus", menus);
		mav.addObject("pfs", pfs);
		mav.setViewName("advantage/dlms");
		return mav;
	}
	
	/**
	 * http://xxx.com/product/cptslbxq
	 * get请求 返回产品特色类别详情页面
	 */
	@RequestMapping(value="/cptslbxq/{productFeatureId}",method=RequestMethod.GET)
	public ModelAndView cptslbxq(@PathVariable Integer productFeatureId){
		List<Menu> menus = menuService.selectMenus();
		
		/**
		 * 查询所有的产品特色
		 */
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("start", 0);
		map.put("pageSize", Integer.MAX_VALUE);
		
		List<ProductFeature> pfs = productFeatureService.selectProductFeatures(map);
		
		ProductFeature pFeature = productFeatureService.selectProductFeatureByProductFeatureId(productFeatureId);
		
		ModelAndView mav = new ModelAndView();
		
		mav.addObject("menus", menus);
		mav.addObject("pfs", pfs);
		mav.addObject("pFeature", pFeature);
		mav.setViewName("advantage/cptslbxq");
		return mav;
	}
	
}
